package com.yanqu.road.server.cmd.activity.washe.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.WasheProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.washe.WasheMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_WASHE_CANCEL_MATCH_FROM_CROSS, desc = "")
public class WasheCancelMatchFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        WasheProto.WasheCancelMatchRespMsg respMsg = WasheProto.WasheCancelMatchRespMsg.parseFrom(packet.getBytes());
        boolean matchSuccess = respMsg.getMatchSuccess();
        if (!matchSuccess) {
            WasheMgr.removePing(packet.getPlayerId());
        }

        WasheProto.WasheCancelMatchRespMsg.Builder builder = WasheProto.WasheCancelMatchRespMsg.newBuilder();
        builder.setMatchSuccess(matchSuccess);
        player.sendPacket(ClientProtocol.U_WASHE_CANCEL_MATCH, builder);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
